Repository navigation
Generate the StackBlitz project files and remove them from the samples - #1152
igdmdimitrov wants to merge 3 commits into
Conversation
…lates Find samples by src/index.tsx instead of package.json, and generate each sample's StackBlitz project (package.json, tsconfig.json, index.html, vite.config.js) with the code-viewer JSON: - package.json lists only the packages the sample imports, at the root versions, plus optional peers (igniteui-react/extras, grid-lite) and the undeclared igniteui-webcomponents dependency of igniteui-react-layouts - tsconfig.json comes from tsconfig.samples.json - index.html and vite.config.js come from templates unless the sample keeps its own - plain .js source files are included (binding-remote-data) versions.js now drives the root package.json only; TOOLING holds the StackBlitz toolchain versions. Docs drop the standalone run and the xplat workflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Delete package.json, tsconfig.json, README.md, index.html and vite.config.js from every sample, along with the leftover sandbox.config.json, .eslintrc.js, .devcontainer and preview images. Samples that need a different index.html (4) or vite.config.js (21 Tailwind, 2 Sass) keep theirs as overrides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
||
| - **Generated**: change the source in igniteui-xplat-examples (the sample's JSON, or `code-gen-library` for data sources and handlers). Patch the sample here as well only when the fix can't wait for the next export, and say so in the PR. Don't restyle generated code (class components, `IgrXxxModule.register()`, `render(): JSX.Element`); it is the generator's output. | ||
| - **Hand-maintained**: function components with hooks, the strict `tsconfig.json` from `npm run add:sample`, and no `register()` calls for `igniteui-react` components, which no longer need them. | ||
| All samples are maintained here. About 560, mostly charts, gauges, maps and grids, were exported from igniteui-xplat-examples, which is no longer used. They use class components, `IgrXxxModule.register()` and `render(): JSX.Element`. Leave that style as it is unless you are rewriting the sample; new samples use function components with hooks and no `register()` calls for `igniteui-react` components, which no longer need them. |
There was a problem hiding this comment.
@igdmdimitrov @ChronosSF xplat still exports React samples to this repo: its sync-downstream-prs.yml targets vnext and master, and IgniteUI/igniteui-xplat-examples#1068 adds another React template with the same project files.
Steps: run the React sync → export --clean rewrites each sample folder from the template → package.json, tsconfig.json, index.html and vite.config.js are back, and the generator takes the last two as overrides.
Is the React export retired? If not, maybe the sync should write only src/ before this merges, and the "Generated and hand-maintained samples" section should stay?
There was a problem hiding this comment.
WC and React PRs updated. Xplat PR here - IgniteUI/igniteui-xplat-examples#1084
igniteui-xplat-examples still exports React samples here, and its template writes a full project per sample. Add check-sample-files.js to check:samples, which CI runs: a sample folder may hold only src/, plus an index.html or vite.config.js that differs from the template. Restore the generated and hand-maintained samples section in AGENTS.md, and the generated-sample wording around skip-type-check.json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| A sample runs in the samples browser (`npm run dev`), which needs no per-sample project files. The docs open it in StackBlitz as a standalone Vite project, built from the code-viewer JSON. `npm run generate:code-viewer` creates that project's files: | ||
|
|
||
| - `package.json`: the packages the sample imports, plus the Ignite UI packages they need alongside (declared peers, and the optional peers listed in `SUBPATH_PEERS`). Versions come from `scripts/lib/versions.js` and the root `package.json`, so a package a sample imports must be a root dependency. | ||
| - `tsconfig.json`: the compiler options of `tsconfig.samples.json`, which `check:samples` uses. |
There was a problem hiding this comment.
VS Code now shows false errors in every sample file (vnext is fine).
Steps: open samples/inputs/checkbox/overview/src/index.tsx in VS Code → "'React' refers to a UMD global" and "Cannot find module or type declarations for side-effect import of './index.css'".
The root tsconfig.json excludes samples/, so the editor falls back to its defaults. Maybe add samples/tsconfig.json with { "extends": "../tsconfig.samples.json" }?
Closes #1151
Summary
Every sample folder held its own
package.json,tsconfig.json,index.html,vite.config.jsandREADME.md, more than 5,000 files across about 1,040 samples. The samples browser doesn't use them. The docs use them only to build the "Edit in StackBlitz" project, and they read them from the generated code-viewer JSON (public/code-viewer/**.json), not from the repo. They come from the igniteui-xplat-examples template, and they drifted: old versions (file-saver1.x,igniteui-theming25) and packages the sample never imports.This PR generates the project files with the code-viewer JSON and removes them from every sample. A sample folder now holds only
src/(the sample and the files it imports). It also keeps its ownindex.htmlorvite.config.jswhen it needs a different one.The PR has three commits. Review the first and the third:
Changes
Sample discovery
src/index.tsx, matchingsamples/**/src/index.tsx, no longerpackage.json. This coverssrc/utils/sample-index.ts,src/utils/samples.tsandscripts/lib/samples.js.scripts/generate-code-viewer.js(rewritten)index.html,tsconfig.json,vite.config.jsandpackage.json.package.jsonlists only what the sample imports. The generator scans JS/TS imports and CSS/SCSS@import/@use/@forwardinsrc/, and the sample's ownvite.config.js. It also adds:igniteui-react/extrasbrings marked, shiki and dompurify;igniteui-react/grid-litebringsigniteui-grid-lite.igniteui-webcomponentsforigniteui-react-layouts, which imports it without declaring it. Without it, the dashboard tile and Excel workbook samples failed to build.sasswhen the sample has a.scssfile, and@types/<pkg>when the root has it.devDependencies.package.json, thenSHAREDandTOOLINGfromscripts/lib/versions.js.@infragistics/names map to their public names. An unknown package falls back to the installed version and prints a warning.tsconfig.jsonis derived fromtsconfig.samples.json, the same optionscheck:samplesuses.index.htmlandvite.config.jscome fromscripts/lib/templates.js, unless the sample has its own..jssource files are now included. This fixesgrids/data-grid/binding-remote-data, which imports a vendoredodatajs-4.0.0.jsthat was missing from its StackBlitz project.Kept overrides
index.html(4):charts/data-chart/type-scatter-polygon-series,type-scatter-polyline-series,excel/spreadsheet/overviewandgrids/grid-lite/styling-config-themes.vite.config.js(23): 21 Tailwind samples, plus 2 Sass ones (grid-litestyling-config-themesandstyling-custom-theme).Scripts, CI and docs
scripts/lib/versions.js:SHAREDupdates the rootpackage.jsonand the StackBlitz projects;TOOLING(TypeScript, React types, Vite and its plugins, Tailwind) is for the StackBlitz projects only. Unused jest, vitest, eslint, tslib and node types are removed.scripts/update-ig.jsupdates only the rootpackage.json, and the CI version-sync step checks only that file.scripts/add-sample.jscreates onlysrc/index.tsxandsrc/index.css.README.mdandAGENTS.md:npm run dev.src/.Check for project files in sample folders
igniteui-xplat-examples still exports samples to this repo. Its template writes a full project per sample, so an export would bring the removed files back.
scripts/check-sample-files.jsruns first innpm run check:samples, which CI runs. A sample folder may hold onlysrc/, plus anindex.htmlorvite.config.jsthat differs from the template.index.htmlalso counts as a copy of ours.node_modulesor build folder in a sample doesn't fail it.skip-type-check.jsonis again for generated samples whose fix has to land in igniteui-xplat-examples.Testing
vnext(1,036 files each):binding-remote-datagained a file: the.jsabove.package.jsonshrank to what each sample imports, at the root versions.npm installandvite buildfrom the registry. All of them built.openProject, as the docs do):vnextproject either, so the problem predates this PR (see Known issues).npm run check: 0 errors.npm run check:samples: the sample folder check passes, and 1,031 samples type-checked.package.json,tsconfig.json,.devcontainer/, andindex.htmlandvite.config.jsas copies of the template.export --clean --sources-onlyinto this branch changed onlysrc/and the check passed.BASE_PATH=/react-demos npm run build: 1,036 pages and 1,036 code-viewer files.npm run test:smoke: 28 passed.Known issues (not changed here)
JSXnamespace, so the StackBlitz editor reportsCannot find namespace 'JSX'in them. The samples still run.skip-type-check.jsonstill need fixes.grids/grid-lite/styling-config-themesnever renders in StackBlitz. It didn't before this PR either. Vite starts, but the page stays blank. The sample compiles 8 Sass themes fromigniteui-theming, and Sass runs in its slow pure-JS mode there.charts/data-chart/type-scatter-polygon-seriesandtype-scatter-polyline-seriesload their data fromstatic.infragistics.com/xplatform/json/airplane-*.json, which currently returns 504 or times out. Without the data, only the legend shows.Follow-ups outside this repo
sync-downstream-prs.yml, not enabled yet) exports with the full template and--clean, which deletes the whole sample folder. That would re-create the project files and remove the overrides. Export only the sample sources to the React and Web Components repos igniteui-xplat-examples#1084 changes the sync to export onlysrc/and to clean only that. Until it lands, the check above catches such an export.🤖 Generated with Claude Code